package com.ll.config;

import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
/**
 * redis 缓存设置，主要是涉及到timeout
 * @author sunhuaili
 *
 */
@Configuration
public class RedisCacheConfiguration implements EnvironmentAware{
	
	private static RelaxedPropertyResolver propertyResolver;
	
	public long getTimeout(String key){
		String val = propertyResolver.getProperty(key);
		return Long.parseLong(val);
	}

	@Override
	public void setEnvironment(Environment environment) {
		RedisCacheConfiguration.propertyResolver = new RelaxedPropertyResolver(environment, "system.redis.timeout.");  
	}
	
}
